#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdbool.h>
bool is_leap_year(int y)
{
	int a = 0;
	if ((a % 4 == 0) && (a % 100 != 0) || (a % 400 == 0))
	{
		return true;
	}
	else
	{
		return false;
	}
}
int is_get_days_of_month(int x, int y)
{
	int days[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int i = days[y];
	if (is_leap_year(y) && y == 2)
	{
		i += 1;
	}
	return i;
}
int main()
{
	int year = 0;
	int month = 0;
	scanf("%d %d", &year, &month);
	int day = is_get_days_of_month(year, month);
		printf("%d\n", day);
		return 0;
}